﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web.Mvc;
using Ninject;
using Ninject.Parameters;
using Ninject.Syntax;
using System.Configuration;
using Chapter3Applications.Models.PersistentModel;
using System.Data.Entity;
using System.Data.Entity.Infrastructure;
using Chapter3Applications.Models.Abstract;
using Chapter3Applications.Models.Concrete;

namespace Chapter3Applications.Infrastructure
{
    public class NinjectDependencyResolver: IDependencyResolver
    {
        IKernel kernel;

        public NinjectDependencyResolver() 
        {
            kernel = new StandardKernel();
            AddBindings();
        }

        public object GetService(Type serviceType)
        {
            return kernel.TryGet(serviceType);
        }

        public IEnumerable<object> GetServices(Type serviceType)
        {
            return kernel.GetAll(serviceType);
        }

        private void AddBindings()
        {
            kernel.Bind<IShoppingListRepository>().To<ShoppingListRepository>();
        }
    }
}